package cn.edu.shengda;

interface ShapeArea {

    public abstract double getArea();

    public abstract double getPerimeter();
}


class Rectangle implements ShapeArea {

    private final double width;
    private final double height;
    public Rectangle(double w, double h) {
        this.width = w;
        this.height = h;
    }
    @Override
    public String toString() {
        String s = "width=" + this.getWidth() + "\n";
        s += "Height=" + this.getHeight() + "\n";
        s += "Perimeter=" + this.getPerimeter() + "\n";
        s += "Area=" + this.getArea() + "\n";
        return s;
    }

    public double getPerimeter() {
        return 2 * (getWidth() + getHeight());
    }

    public double getArea() {
        return getHeight() * getWidth();
    }

    /**
     * @return the width
     */
    public double getWidth() {
        return width;
    }

    /**
     * @return the height
     */
    public double getHeight() {
        return height;
    }
}


class Circle implements ShapeArea {

    double radius;

    Circle(double r) {
        radius = r;
    }

    public double getArea() {

        return 3.14 * radius * radius;

    }

    public double getPerimeter() {

        return 2 * 3.14 * radius;

    }

    public String toString() {

        return "radius=" + radius + ",perimeter=" + getPerimeter() + ",area=" + getArea();

    }

}

public class Test {

    public static void main(String args[]) {
        if (args.length < 2) {
            System.out.println("请在命令行输入两参数！");
        }
        double width = Integer.parseInt(args[0]);
        double height = Integer.parseInt(args[1]);
        Rectangle rec = new Rectangle(width, height);
        System.out.println("该矩形的信息如下：");
        System.out.println(rec);

        Circle c = new Circle(1.0);

        System.out.println(c.toString());

    }

}